/*
 * GPS_PublicPositionData.h
 *
 *  Created on: 2015-10-20
 *      Author: Administrator
 */

#ifndef GPS_PUBLICPOSITIONDATA_H_
#define GPS_PUBLICPOSITIONDATA_H_

#include <std.h>
#include "GPS_Location_Handle.h"



////////////////////////////////////////////////////////////////
//  GPS public position data structure:
////////////////////////////////////////////////////////////////
struct BYTEOFWORD
{
	Uns LSByte:8; //transmitted firstly
	Uns MSByte:8; //transmitted secondly
};
union WORD_REG
{
	Uns all;
	struct BYTEOFWORD sbyte;
};
//all=0x1234 is equal to bit.LSByte=0x34,bit.MSByte=0x12

typedef struct{
  Uns Name[4];
  Uns ID;
  Uns Phone[4];
}MINI_ST_DATA, *pMINI_ST_DATA;

typedef struct {
  union WORD_REG CodeAddr;	//Code is MSByte, and Addr is LSByte.
  union WORD_REG RdName0Flag;
  union WORD_REG RdName2_1;
  union WORD_REG RdName4_3;
  union WORD_REG RdName6_5;
  union WORD_REG ID0RdName7;
  union WORD_REG DpName0ID1;
  union WORD_REG DpName2_1;
  union WORD_REG DpName4_3;
  union WORD_REG DpName6_5;
  union WORD_REG DpName8_7;
  union WORD_REG DpName10_9;
  union WORD_REG DpName12_11;
  union WORD_REG DpName14_13;
  union WORD_REG DpName16_15;
  union WORD_REG DpName18_17;
  union WORD_REG DpName20_19;
  union WORD_REG lon0Mode;
  union WORD_REG lon2lon1;
  union WORD_REG lon4lon3;
  union WORD_REG lat1lat0;
  union WORD_REG lat3lat2;
  union WORD_REG MonthYear;
  union WORD_REG HourDate;
  union WORD_REG SecondMinute;
  union WORD_REG DpPhone1_0;
  union WORD_REG DpPhone3_2;
  union WORD_REG DpPhone5_4;
  union WORD_REG DpPhone7_6;
  MINI_ST_DATA St[4];
  Uns rsvd[10];
}GPS_PUB_DATA, *pGPS_PUB_DATA;

//public position information sturcture for UsartData
typedef struct{	Uns DataLen;
				union WORD_REG SrcLen_SrcPort;
				union WORD_REG DestLen_DestPort;
				union WORD_REG Cmd_CmdType;
				GPS_PUB_DATA GpsData;
				Uns Crc;
}STD_GPS_REC, *pSTD_GPS_REC;


void PrepareUartDataForPPD(void);
void SetGpsPosData(void);
void SetErrorCode(Uns error);
void ST_INFO_TO_MINI_ST_DATA(MINI_ST_DATA* mini_st,ST_INFO* whole_st);
void SetGpsRecInvalid(void);
void GpsTimeHandler(void);
void CleanCurrGps_St(Uns index);
void RefreshRoadInfo(Uns rdindex);
void RefreshStationInfo();
void ByteCopyForWordStructure(Uns *DesByteP,Uns DesF,Uns *SrsByteP,Uns SrsF,Uns ByteLen);

#endif /* GPS_PUBLICPOSITIONDATA_H_ */
